function handle=pcolorim(ax,X,Y,Z,increasefactorx,increasefactory)
[nothing uniquecols]=unique(X(1,:)); [nothing uniqerows]=unique(Y(:,1));
X=X(uniqerows,uniquecols); Y=Y(uniqerows,uniquecols); Z=Z(uniqerows,uniquecols);
%Z(isnan(Z))=min(Z(:));
x=X(1,:); y=Y(:,1); dx=diff(x); dy=diff(y);
gridsizex=min(dx)/increasefactorx; gridsizey=min(dy)/increasefactory;
display(['pcolor resolution: ' num2str(length(x)) ' x ' num2str(length(y))]);
display(['Image resolution: ' num2str((max(x)-min(x))/gridsizex+1) ' x ' num2str((max(y)-min(y))/gridsizey+1)]);
xi=linspace(min(x),max(x),(max(x)-min(x))/gridsizex+1); yi=linspace(min(y),max(y),(max(y)-min(y))/gridsizey+1);
Z=interp2(X,Y,Z,xi,yi'); X=[min(x) max(x)]; Y=[min(y) max(y)];
%handle=imagesc(X,Y,Z,'parent',ax); set(ax,'ydir','normal');
handle=imagesc(X,Y,Z); set(gca,'ydir','normal');
%alpha=get(handle,'cdata'); alpha(~isnan(alpha))=1; alpha(isnan(alpha))=0; set(handle,'alphaData',alpha);
